package com.sos.ui
{ 
    import flash.display.MovieClip; 
	import flash.events.MouseEvent;
	import flash.media.Sound
     
    public class Die_White extends MovieClip 
    { 
		// Set initial values
		public var allowRotation:Boolean = true; //Allow the dice to rotate a bit on stage
		public var rollSound:Boolean = true; //Allow the sound effect to play when the die is rolled

		public var faceValue:int = 6;
		
		private var dieRollSound:Sound;
	
		public function Die_White() {
			

			/////////////////////////////////////////////////////////////
			//
			//			GAME-READY DICE		by AerisTech
			//
			/////////////////////////////////////////////////////////////

			stop();

			if(rollSound) {
				dieRollSound = new DieRollSound();
			}

			// Add mouse click functionality to roll the die
			//addEventListener(MouseEvent.CLICK, onClickDie, false, 0, true);
			mouseChildren = false;
			buttonMode = true;

		} 
		
		public function onClickDie(e:MouseEvent):void {
			removeEventListener(MouseEvent.CLICK, onClickDie);
			buttonMode = false;
			roll();
		}
		
		public function roll(value:uint = 0):void {
			if (value != 0)
				faceValue = value;
			//trace("Facevalue is " + faceValue);
			// Initiate the roll-out sequence
			if(faceValue == 6) {
				gotoAndPlay("rollout6");
			} else if(faceValue == 5) {
				gotoAndPlay("rollout5");
			} else if(faceValue == 4) {
				gotoAndPlay("rollout4");
			} else if(faceValue == 3) {
				gotoAndPlay("rollout3");
			} else if(faceValue == 2) {
				gotoAndPlay("rollout2");
			} else {
				gotoAndPlay("rollout1");
			}
			
			if(rollSound) {
				dieRollSound.play();
			}
		}
		
    } 
}